
# KERNELDIR := /home/linux/ubuntu-linux-kernel/linux-5.4
# obj-m := Char_dev.o
# PWD = $(shell pwd)
# modules:
# 	$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
# clean:
# 	rm -rf *.o *.ko *.mod.* *.symvers *.order *.mod
# .PHONY: modules clean

#vi Makefile
#交叉编译工具, 根据实际使用的编译工具指定， 有可能是arm-none-linux-gnueabi-、arm-eabi-gcc，aarch64-linux-gnu-等等
export CROSS_COMPILE := arm-linux-gnueabihf-
export ARCH := arm
CC := $(CROSS_COMPILE)gcc
LD := $(CROSS_COMPILE)ld
 #指定要编译的板子内核为arm 32位版本，如果是64位系统，则修改为arm64


obj-m := ads8689_driver.o 

#使用的内核路径
LINUXDIR=/home/linux/i.MX6ull/i.MX6ull-kernel_ATK

PWD=$(shell pwd)  #当前路径

modules:        
	$(MAKE) ARCH=$(ARCH) -C $(LINUXDIR) M=$(PWD) modules 
	$(CROSS_COMPILE)gcc main.c -o main
clean:
	rm -rf *.o *.ko *.mod.* *.symvers *.order .*.cmd
scp_modules:
	scp ./*.ko main root@192.168.0.46:/home/root/driver/ads8689
.PHONY: modules clean
